import { getInfo, getRouters } from '@/api'
export default {
    state: {
        userInfo: {},
        routers: []
    },
    mutations: {
        setUserInfo(state, data) {
            state.userInfo = data
        },
        setRouters(state, data){
            state.routers = data
        }
    },
    actions: {
        getInfo() {
            return new Promise((resolve, reject)=>{
                getInfo().then(res=>{
                    this.commit('setUserInfo', res.data)
                    resolve(res)
                }).catch(err=>{
                    reject(err)
                })
            })
        },
        getRouters(){
            return new Promise((resolve, reject)=>{
                getRouters().then(res=>{
                    this.commit('setRouters', res.data)
                    resolve(res)
                }).catch(err=>{
                    reject(err)
                })
            })
        }
    }
}